/**
 * @author Vitor Franco do Carmo (vitor.carmo@cpmbraxis.com)
 * @since 06/08/2013
 *
 */
package br.com.vfcfw.test.functional.browser;

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

/**
 * Classe responsável por rodar o Firefox nos testes funcionais.
 * 
 * @author Vitor Franco do Carmo (vitor.carmo@cpmbraxis.com)
 * @since 06/08/2013
 * 
 */
public class FirefoxNavegador implements INavegador {

    private static FirefoxBinary binary;

    private static WebDriver driver;

    /**
     * {@inheritDoc}
     * 
     * @see br.com.vfcfw.test.functional.browser.INavegador#inicializarServico()
     */
    @Override
    public void inicializarServico() {

        binary = new FirefoxBinary(new File("/Applications/Firefox.app/Contents/MacOS/firefox-bin"));
    }

    /**
     * {@inheritDoc}
     * 
     * @see br.com.vfcfw.test.functional.browser.INavegador#finalizarServico()
     */
    @Override
    public void finalizarServico() {

        binary.quit();
    }

    /**
     * {@inheritDoc}
     * 
     * @see br.com.vfcfw.test.functional.browser.INavegador#inicializarTeste()
     */
    @Override
    public void inicializarTeste() {

        FirefoxProfile profile = new FirefoxProfile();
        driver = new FirefoxDriver(binary, profile);
    }

    /**
     * {@inheritDoc}
     * 
     * @see br.com.vfcfw.test.functional.browser.INavegador#finalizarTeste()
     */
    @Override
    public void finalizarTeste() {

        driver.close();
    }

    /**
     * {@inheritDoc}
     * 
     * @see br.com.vfcfw.test.functional.browser.INavegador#obterDriver()
     */
    @Override
    public WebDriver obterDriver() {

        return driver;
    }

}
